define("pages/jls_cs/xmcsmain", [
        "../../plugins/easyui/jquery-easyui-1.5.1/jquery.easyui.min",
        "../../plugins/easyui/jquery-easyui-1.5.1/easyloader",
        "../../plugins/artTemplate/artTemplate",
        "../../common/tools",
        "../../common/kss",
        "../../common/componts",
        "../../pages/jls_cs/gjhdform.js"
    ],
    function(require) {

        var comonts=require("../../common/componts");
        var kss=require("../../common/kss");
        var gjhdjbxxId="gjhdjbxxId";
        var jscx = "jscx";
        var gjhdform=require("../../pages/jls_cs/gjhdform");

        var initHtml = function(){
            var user_permission = 2 ; 	//设置获取到的用户权限
            var rsdj_permission = 2 ;	//设置出所管理需要的权限
            var container = document.getElementById("main");
            var graph = new mxGraph(container);
            var parent = graph.getDefaultParent();

            graph.setHtmlLabels(true);

            graph.setEnabled(false);

            var style = {};

            style = graph.getStylesheet().getDefaultEdgeStyle();//圆角连线
            style[mxConstants.STYLE_ROUNDED] = true;//圆角连线
            style = mxUtils.clone(style);
            style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_LABEL;  // 不设置这个属性 背景图片不出来

            style[mxConstants.STYLE_STROKECOLOR] = '#f5f5f5';

            style[mxConstants.STYLE_FILLCOLOR] = '#f5f5f5';

            style[mxConstants.STYLE_FONTCOLOR] = 'black';

            style[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER;

            style[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_BOTTOM;

            style[mxConstants.STYLE_FONTSIZE] = 13;

            style[mxConstants.STYLE_IMAGE_ALIGN] = 0;

            style[mxConstants.STYLE_IMAGE_VERTICAL_ALIGN] = 0;

            style[mxConstants.STYLE_IMAGE] = '../../img/lcttx.png';

            style[mxConstants.STYLE_IMAGE_WIDTH] = 80;

            style[mxConstants.STYLE_IMAGE_HEIGHT] = 80;

            style[mxConstants.STYLE_SPACING_TOP] = 30;

            style[mxConstants.STYLE_SPACING] = 0.5;

            graph.getStylesheet().putCellStyle("style1", style);

            var style2 = {};

            style2 = graph.getStylesheet().getDefaultEdgeStyle();//圆角连线
            style2[mxConstants.STYLE_ROUNDED] = true;//圆角连线
            style2 = mxUtils.clone(style);
            style2[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_LABEL;  // 不设置这个属性 背景图片不出来

            style2[mxConstants.STYLE_STROKECOLOR] = '#f5f5f5';

            style2[mxConstants.STYLE_FILLCOLOR] = '#f5f5f5';

            style2[mxConstants.STYLE_FONTCOLOR] = 'black';

            style2[mxConstants.STYLE_ALIGN] = mxConstants.ALIGN_CENTER;

            style2[mxConstants.STYLE_VERTICAL_ALIGN] = mxConstants.ALIGN_BOTTOM;

            style2[mxConstants.STYLE_FONTSIZE] = 13;

            style2[mxConstants.STYLE_IMAGE_ALIGN] = 0;

            style2[mxConstants.STYLE_IMAGE_VERTICAL_ALIGN] = 0;

            style2[mxConstants.STYLE_IMAGE] = '../../img/zh.png';

            style2[mxConstants.STYLE_IMAGE_WIDTH] = 80;

            style2[mxConstants.STYLE_IMAGE_HEIGHT] = 80;

            style2[mxConstants.STYLE_SPACING_TOP] = 30;

            style2[mxConstants.STYLE_SPACING] = 0.5;

            graph.getStylesheet().putCellStyle("style2", style2);




            //获取流程节点的待办数量
            var jbdjCount=0;
            var jbqrCount=0;



            // 画人物
            var v1 = graph.insertVertex(parent, 'gjhd', '管教核定<font color="jbdj"></font>', 300, 220, 100, 105, "style1");

            var v2 = graph.insertVertex(parent, 'szsp', '所长审批<font color="jbqr"></font>', 500, 220, 100, 105, "style2");

            var v3 = graph.insertVertex(parent, 'kzdy', '开证打印<font color="jbqr"></font>', 700, 220, 100, 105, "style2");
            var v4 = graph.insertVertex(parent, 'fwfh', '附物返还<font color="jbqr"></font>', 700, 100, 100, 105, "style2");

            var v5 = graph.insertVertex(parent, 'cs', '出所<font color="jbqr"></font>', 900, 220, 100, 105, "style2");





            // 连线
            graph.insertEdge(parent, null, '',v1, v2 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v2, v3 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v3, v5 , "edgeStyle=elbowEdgeStyle;");
            graph.insertEdge(parent, null, '',v2, v4 , "edgeStyle=elbowEdgeStyle;");





            //添加事件
            graph.addListener(mxEvent.CLICK, function(sender, evt) {
                var cell11 = evt.getProperty('cell');
                //graph.setCellStyles(fillColor,black);
                if(cell11==null){
                    $("#pictureId").css({"display":"none"});
                    return ;
                }else if(cell11.id=='gjhd'){
                    window.location.href="/jls_cs/gjhd.html";
                }else if (cell11.id=='ksrs'){
                    window.location.href='';
                }else if(cell11.id=='jydj'){

                }
            });
            //鼠标悬浮效果
            var track = new mxCellTracker(graph);
            var self = this;
            track.mouseMove = function(sender, me) {
                var cell1 = this.getCell(me);
                if(cell1==null){
                    $("#pictureId").css({"display":"none"});
                    return ;
                }else{
                    if(cell1.id=="tscldj"){
                        $("#pictureId").css({"display":"block","left":"250px","top":"170px"});
                        $("#pictureId").html("投诉处理登记登记！");
                    }else if (cell1.id=="ldsp"){
                        $("#pictureId").css({"display":"block","left":"550px","top":"170px"});
                        $("#pictureId").html("领导审批！");
                    }else if (cell1.id=="cldjcljg"){
                        $("#pictureId").css({"display":"block","left":"850px","top":"170px"});
                        $("#pictureId").html("登记处理结果！");
                    }
                }
            };
            //
            function bodyScale(){
                var main = document.getElementById("main"); //获取id="main"
                var devicewidth=document.documentElement.clientWidth;
                var scale=devicewidth/1275;//除去当前流量器分辨率1275
                main.style.zoom=scale;//zoom是设置或检索对象的缩放比例.
            }
            window.onload=window.onresize=function(){
                bodyScale();
            }

        };

        var tableInit = function(){
            comonts.initTable(gjhdjbxxId,{
                url:"/jls_jbxx/jbxxList",
                title:'',
                fit:true,
                tools:'#gjhdyc',
                columns :  [
                    {
                        field: 'oid',
                        title: '序号',
                        formatter: function(value, rowData, rowIndex){
                            return '<input type="radio" name="ryRadiows" id="ryRadiows' + rowIndex + '" value="' + rowData.oid + '" />';
                        }},
                    {field : 'jsh',width : 30,title:'拘室号',sortable:'true',formatter: function(value,row,index){return '<span title='+(row.jsh==null?"":row.jsh)+'>'+(row.jsh==null?"":row.jsh)+'</span>'}},
                    {field : 'yfh',title : '衣服号',width : 50,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.xm==null?"":row.xm)+'>'+(row.xm==null?"":row.xm)+'</span>'}},
                    {field : 'xm',title : '姓名',width : 30,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},

                    {field : 'xbString',title : '性别',width : 50,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.xbString==null?"":row.xbString)+'>'+(row.xbString==null?"":row.xbString)+'</span>'}},
                    {field : 'ab',title : '案别',width : 50,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.ab==null?"":row.ab)+'>'+(row.ab==null?"":row.ab)+'</span>'}},
                    {field : 'rsrq',title : '入所日期',width : 50,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.rsrq==null?"":row.rsrq)+'>'+(row.rsrq==null?"":row.rsrq)+'</span>'}},
                    {field : 'jlqx',title : '拘留期限（日）',width : 80,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},
                    {field : 'jlzxqx',title : '拘留执行期限止',width : 80,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},
                    {field : 'bz',title : '备注',width : 80,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},
                    {field:'operate',title:'详细信息',align:'center',width : 60,/*width:$(this).width()*0.15,*/
                        formatter:function(value, row, index){
                            var str = '<a href="#" data-target="#ckPhoto"  name="opera" data-toggle="modal" class="easyui-linkbutton"><img src="../../img/xq.png"></a>';
                            return str;
                            //return  '<button id="sh_add" onclick="add"  > 不通过</button>'
                        }
                    }
                ] ,
                //基本信息双击事件
                onDblClickRow:function(rowIndex, rowData){
                    $("input[name='ryRadiows']")[rowIndex].checked = true;
                    $("#"+gjhdjbxxId).datagrid("selectRow", rowIndex);
                    selectid=rowData.id;
                },

                onLoadSuccess:function(data){
                    if(data.total>0){
                        $('#'+gjhdjbxxId).datagrid("selectRow", 0);
                        $("input[name='ryRadiows']")[0].checked = true;
                    }
                    $("a[name='opera']").on('click',function(){
                        var jbxx = $('#'+gjhdjbxxId).datagrid("getSelected");
                        kss.initJbxxxx(jbxx.gcbh,jbxx.rybh,jbxx.xm+"--详细信息");
                    });
                },

                onClickRow:function(rowIndex, rowData){
                    if(selectid!=rowData.id){
                        $("input[name='ryRadiows']")[rowIndex].checked = true;
                        selectid=rowData.id;
                    }else{
                        $("#"+gjhdjbxxId).datagrid("unselectRow",rowIndex);
                        $("input[name='ryRadiows']")[rowIndex].checked = false;
                        $('#'+gjhdjbxxId).datagrid('clearSelections');
                        selectid="";
                    }
                    kss.zjryClick(rowData);
                },
                onSelect:function(rowIndex, rowData){
                },
                rightmenu:function(){
                    //kss.initJbxxRightMenu(jbxxrightmenuid);
                },
            });
            //页面高度自适应
            $('#'+gjhdjbxxId).datagrid('resize',{
                height:($(window).height()-150),
            });
        }

        var findxmcs=function(){
            var opts = $('#'+gjhdjbxxId).datagrid("options");
            opts.url = "/jls_jbxx/jbxxList";
            $('#'+gjhdjbxxId).datagrid('clearSelections');
            $('#'+gjhdjbxxId).datagrid('load',{
            });
        };

        var bindAction=function(){
            $("#xmcs_search").on("click",function(){
                findxmcs();
            });

            $("#gjhd_csdj").on("click",function(){

                gjhdform.show({},{},{})
            });
        }


        var jscxtable = function(){
            comonts.initTable(jscx,{
                url:"/jls_jbxx/jbxxList",
                title:'',
                fit:true,
                tools:'#xscxId',
                columns :  [
                    {
                        field: 'oid',
                        title: '序号',
                        formatter: function(value, rowData, rowIndex){
                            return '<input type="radio" name="ryRadio" id="ryRadio' + rowIndex + '" value="' + rowData.oid + '" />';
                        }},
                    {field : 'jsh',width : 30,title:'拘室号',sortable:'true',formatter: function(value,row,index){return '<span title='+(row.jsh==null?"":row.jsh)+'>'+(row.jsh==null?"":row.jsh)+'</span>'}},
                    {field : 'yfh',title : '衣服号',width : 50,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.xm==null?"":row.xm)+'>'+(row.xm==null?"":row.xm)+'</span>'}},
                    {field : 'xm',title : '姓名',width : 30,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},

                    {field : 'xbString',title : '性别',width : 50,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.xbString==null?"":row.xbString)+'>'+(row.xbString==null?"":row.xbString)+'</span>'}},
                    {field : 'ab',title : '案别',width : 50,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.ab==null?"":row.ab)+'>'+(row.ab==null?"":row.ab)+'</span>'}},
                    {field : 'rsrq',title : '入所日期',width : 50,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.rsrq==null?"":row.rsrq)+'>'+(row.rsrq==null?"":row.rsrq)+'</span>'}},
                    {field : 'jlqx',title : '拘留期限（日）',width : 80,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},
                    {field : 'jlzxqx',title : '拘留执行期限止',width : 80,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},
                    {field : 'bz',title : '备注',width : 80,sortable:'true',formatter: function(value,row,index){return '<span title='+(row.bm==null?"":row.bm)+'>'+(row.bm==null?"":row.bm)+'</span>'}},
                    {field:'operate',title:'详细信息',align:'center',width : 60,/*width:$(this).width()*0.15,*/
                        formatter:function(value, row, index){
                            var str = '< a href=" " data-target="#ckPhoto"  name="opera" data-toggle="modal" class="easyui-linkbutton">< img src="../../img/xq.png"></ a>';
                            return str;
                            //return  '<button id="sh_add" onclick="add"  > 不通过</button>'
                        }
                    }
                ] ,
                //基本信息双击事件
                onDblClickRow:function(rowIndex, rowData){
                    $("input[name='ryRadio']")[rowIndex].checked = true;
                    $("#"+gjhdjbxxId).datagrid("selectRow", rowIndex);
                    selectid=rowData.id;
                },

                // onLoadSuccess:function(data){
                // 	if(data.total>0){
                // 		$('#'+gjhdjbxxIdgjhdjbxxId).datagrid("selectRow", 0);
                // 		$("input[name='ryRadio']")[0].checked = true;
                // 	}
                //
                // 	$("a[name='opera']").on('click',function(){
                // 			var jbxx = $('#'+gjhdjbxxId).datagrid("getSelected");
                // 			kss.initRyJbxx(jbxx);
                // 	});
                // 	$('.datagrid-pager').find('.pagination-info').css('margin-right','25px');
                //
                // },

                onLoadSuccess:function(data){
                    if(data.total>0){
                        $('#'+gjhdjbxxId).datagrid("selectRow", 0);
                        $("input[name='ryRadio']")[0].checked = true;
                    }
                    $("a[name='opera']").each(function(){
                        $(this).on('click',function () {
                            var index = $(this).attr('value');
                            var jbxx = data.rows[index];
                            kss.initJbxxxx(jbxx.gcbh,jbxx.rybh,jbxx.xm+"--详细信息");
                        });
                    });
                },

                //单击行选中取消事件
                onClickRow:function(rowIndex, rowData){
                    if(selectid!=rowData.id){
                        $("input[name='ryRadio']")[rowIndex].checked = true;
                        selectid=rowData.id;
                    }else{
                        $("#"+gjhdjbxxId).datagrid("unselectRow",rowIndex);
                        $("input[name='ryRadio']")[rowIndex].checked = false;
                        $('#'+gjhdjbxxId).datagrid('clearSelections');
                        selectid="";
                    }
                },
                onSelect:function(rowIndex, rowData){
                },
                rightmenu:function(){
                    //kss.initJbxxRightMenu(jbxxrightmenuid);
                },
            });
            //页面高度自适应
            $('#'+jscx).datagrid('resize',{
                height:($(window).height()-150),
            });
        }





        var initView=function(){
            console.info("进入rsdj的sea.js");
            initHtml();
            tableInit();
            jscxtable();
            bindAction();
        }
        initView();

    });
